<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>证券市场变动表</title>
    <!--导入layui包-->
    <link rel="stylesheet" href="../layui/css/layui.css"/>
    <script src="../jQuery/jquery-1.11.2.js"></script>
    <script src="../layui/layui.js"></script>
    <link rel="stylesheet" type="text/css" href="/css/font.css">
</head>
<body>
<blockquote class="layui-elem-quote news_search">
    <!--数据表格-->
    <table class="layui-hide" id="DayStatement" lay-filter="secStockList"></table>

    <script type="text/html" id="day_search">
        <!--多条件查询层-->
        <div class="layui-inline">
            证券名称:
            <div class="layui-input-inline">
                <select name="seName" id="seName">
                    <option value="">---请选择---</option>
                </select>
            </div>
            <button id="search" class="layui-btn  layui-btn-primary layui-bg-gray" lay-submit data-type="reload"
                    lay-filter="provinceSearch">
                <i class="layui-icon">&#xe615;</i>
            </button>
        </div>
    </script>

    <!--脚本代码-->
    <script type="text/javascript">
        layui.use('table', function () {
            //导入模块并得到模块对象
            var table = layui.table,
                form = layui.form;//表单对象;
            var tables;
            var vals="";
            var varseName="<option value=''>--请选择--</option>";
            //开关用于避免重复添加搜索框
            var tufa=false;
            //开关用于避免重复执行
            var tafa=true;
            var two;
            //渲染表格对象
            tables=table.render({
                elem: "#DayStatement",//表格对象
                url: "/Statisical/stat",//后台服务路径
                method: "get",//提交方式
                height: 1100,
                toolbar: "#day_search",//表格上方普通工具栏
                //一页显示5条数据
                limit: 5,
                cols: [
                    [
                        {checkbox: true},//开启多选框
                        {field: "seId", title: "证券代码", align: "center"},
                        {field: "seName", title: "证券名称", align: "center"},
                        {field: "secNum", title: "库存数量（支）", align: "center"},
                        {field: "costs", title: "单位成本（元）", align: "center"},
                        {field: "qprice", title: "行情价格（元）", align: "center"},
                        {field: "marValue", title: "市值变动比（%）", align: "center"},
                        {field: "markets", title: "市值占净值比（%）", align: "center"},
                        {field: "tranDate", title: "交易日期", align: "center"}
                    ]
                ],
                parseData:function (res) {
                    var datasTwo = new Array();
                    //证券
                    two = res.securi;
                    var twoStr = "<option value=''>--请选择--</option>";
                    for (var i = 0; i < two.length; i++) {
                        twoStr += "<option value='" + two[i].seName + "'>" + two[i].seName + "</option>";
                    }
                    $("#seName").html(twoStr);
                    for (var i = 0; i < res.data.length; i++) {
                        if (vals == "") {
                            datasTwo.push(res.data[i]);
                        } else if (res.data[i].seName == vals) {
                            datasTwo.push(res.data[i]);
                        }
                    }
                    return {
                        "code": res.code,
                        "msg": res.msg,
                        "count": datasTwo.length,
                        "data": datasTwo
                    }
                },
                page: true,
                //一页选择显示5或10条数据
                limits: [5, 10]
            });
            form.on("submit(provinceSearch)",function (data) {
                vals=data.field.seName;
                /* //定义表单数据对象
                 var formData=data.field;
                 //得到表单数据json字符串
                 var json=JSON.stringify(data.field);*/
                //alert(json);
                //重新加载表格对象
                tables.reload("secStockList");
                /*return false;*/
            });
        });
    </script>
</blockquote>
</body>
</html>